# Importing Data
PHILIPINESS<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Rubber/Rubber.xlsx",sheet = "Sheet1", range = "h1:h325")

# Checking the Imported Data
View(PHILIPINESS)
# Creating Time Series Data
PHILIPINESS_ts <- ts(PHILIPINESS, start=c(1991,1), end=c(2017,12), frequency=12)
# Viewing and Checking the Created Time Series Data
PHILIPINESS_ts
sum(is.na(PHILIPINESS_ts))
library(forecast)
PHILIPINESS_ts <- tsclean(PHILIPINESS_ts)
PHILIPINESS_ts

# Identification: Plotting the Time Series Data
plot(PHILIPINESS_ts)

# Estimating the appropriate model
PHILIPINESS_ts_model <- auto.arima(PHILIPINESS_ts)
PHILIPINESS_ts_model

# Forecasting
options(max.print=1000000)
PHILIPINESS_ts_forecast <- forecast (PHILIPINESS_ts_model, level=c(95), h=276)
plot(PHILIPINESS_ts_forecast)
PHILIPINESS_ts_forecast             

# Exporting
write.table(PHILIPINESS_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Rubber/PHILIPINESS_TSA.csv", sep=",")


